//===----------------------------------------------------------------------===//
//
// This source file is part of the Soto for AWS open source project
//
// Copyright (c) 2017-2024 the Soto project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of Soto project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//

// THIS FILE IS AUTOMATICALLY GENERATED by https://github.com/soto-project/soto-codegenerator.
// DO NOT EDIT.

#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
@_exported import SotoCore

/// Service object for interacting with AWS ApplicationCostProfiler service.
///
/// This reference provides descriptions of the AWS Application Cost Profiler API. The AWS Application Cost Profiler API provides programmatic access to view, create, update, and delete application cost report definitions, as well as to import your usage data into the Application Cost Profiler service. For more information about using this service, see the AWS Application Cost Profiler User Guide.
public struct ApplicationCostProfiler: AWSService {
    // MARK: Member variables

    /// Client used for communication with AWS
    public let client: AWSClient
    /// Service configuration
    public let config: AWSServiceConfig

    // MARK: Initialization

    /// Initialize the ApplicationCostProfiler client
    /// - parameters:
    ///     - client: AWSClient used to process requests
    ///     - region: Region of server you want to communicate with. This will override the partition parameter.
    ///     - partition: AWS partition where service resides, standard (.aws), china (.awscn), government (.awsusgov).
    ///     - endpoint: Custom endpoint URL to use instead of standard AWS servers
    ///     - middleware: Middleware chain used to edit requests before they are sent and responses before they are decoded 
    ///     - timeout: Timeout value for HTTP requests
    ///     - byteBufferAllocator: Allocator for ByteBuffers
    ///     - options: Service options
    public init(
        client: AWSClient,
        region: SotoCore.Region? = nil,
        partition: AWSPartition = .aws,
        endpoint: String? = nil,
        middleware: AWSMiddlewareProtocol? = nil,
        timeout: TimeAmount? = nil,
        byteBufferAllocator: ByteBufferAllocator = ByteBufferAllocator(),
        options: AWSServiceConfig.Options = []
    ) {
        self.client = client
        self.config = AWSServiceConfig(
            region: region,
            partition: region?.partition ?? partition,
            serviceName: "ApplicationCostProfiler",
            serviceIdentifier: "application-cost-profiler",
            serviceProtocol: .restjson,
            apiVersion: "2020-09-10",
            endpoint: endpoint,
            errorType: ApplicationCostProfilerErrorType.self,
            middleware: middleware,
            timeout: timeout,
            byteBufferAllocator: byteBufferAllocator,
            options: options
        )
    }





    // MARK: API Calls

    /// Deletes the specified report definition in AWS Application Cost Profiler. This stops the report from being generated.
    @Sendable
    @inlinable
    public func deleteReportDefinition(_ input: DeleteReportDefinitionRequest, logger: Logger = AWSClient.loggingDisabled) async throws -> DeleteReportDefinitionResult {
        try await self.client.execute(
            operation: "DeleteReportDefinition", 
            path: "/reportDefinition/{reportId}", 
            httpMethod: .DELETE, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Deletes the specified report definition in AWS Application Cost Profiler. This stops the report from being generated.
    ///
    /// Parameters:
    ///   - reportId: Required. ID of the report to delete.
    ///   - logger: Logger use during operation
    @inlinable
    public func deleteReportDefinition(
        reportId: String,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> DeleteReportDefinitionResult {
        let input = DeleteReportDefinitionRequest(
            reportId: reportId
        )
        return try await self.deleteReportDefinition(input, logger: logger)
    }

    /// Retrieves the definition of a report already configured in AWS Application Cost Profiler.
    @Sendable
    @inlinable
    public func getReportDefinition(_ input: GetReportDefinitionRequest, logger: Logger = AWSClient.loggingDisabled) async throws -> GetReportDefinitionResult {
        try await self.client.execute(
            operation: "GetReportDefinition", 
            path: "/reportDefinition/{reportId}", 
            httpMethod: .GET, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Retrieves the definition of a report already configured in AWS Application Cost Profiler.
    ///
    /// Parameters:
    ///   - reportId: ID of the report to retrieve.
    ///   - logger: Logger use during operation
    @inlinable
    public func getReportDefinition(
        reportId: String,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> GetReportDefinitionResult {
        let input = GetReportDefinitionRequest(
            reportId: reportId
        )
        return try await self.getReportDefinition(input, logger: logger)
    }

    /// Ingests application usage data from Amazon Simple Storage Service (Amazon S3). The data must already exist in the S3 location. As part of the action, AWS Application Cost Profiler copies the object from your S3 bucket to an S3 bucket owned by Amazon for processing asynchronously.
    @Sendable
    @inlinable
    public func importApplicationUsage(_ input: ImportApplicationUsageRequest, logger: Logger = AWSClient.loggingDisabled) async throws -> ImportApplicationUsageResult {
        try await self.client.execute(
            operation: "ImportApplicationUsage", 
            path: "/importApplicationUsage", 
            httpMethod: .POST, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Ingests application usage data from Amazon Simple Storage Service (Amazon S3). The data must already exist in the S3 location. As part of the action, AWS Application Cost Profiler copies the object from your S3 bucket to an S3 bucket owned by Amazon for processing asynchronously.
    ///
    /// Parameters:
    ///   - sourceS3Location: Amazon S3 location to import application usage data from.
    ///   - logger: Logger use during operation
    @inlinable
    public func importApplicationUsage(
        sourceS3Location: SourceS3Location,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> ImportApplicationUsageResult {
        let input = ImportApplicationUsageRequest(
            sourceS3Location: sourceS3Location
        )
        return try await self.importApplicationUsage(input, logger: logger)
    }

    /// Retrieves a list of all reports and their configurations for your AWS account. The maximum number of reports is one.
    @Sendable
    @inlinable
    public func listReportDefinitions(_ input: ListReportDefinitionsRequest, logger: Logger = AWSClient.loggingDisabled) async throws -> ListReportDefinitionsResult {
        try await self.client.execute(
            operation: "ListReportDefinitions", 
            path: "/reportDefinition", 
            httpMethod: .GET, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Retrieves a list of all reports and their configurations for your AWS account. The maximum number of reports is one.
    ///
    /// Parameters:
    ///   - maxResults: The maximum number of results to return.
    ///   - nextToken: The token value from a previous call to access the next page of results.
    ///   - logger: Logger use during operation
    @inlinable
    public func listReportDefinitions(
        maxResults: Int? = nil,
        nextToken: String? = nil,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> ListReportDefinitionsResult {
        let input = ListReportDefinitionsRequest(
            maxResults: maxResults, 
            nextToken: nextToken
        )
        return try await self.listReportDefinitions(input, logger: logger)
    }

    /// Creates the report definition for a report in Application Cost Profiler.
    @Sendable
    @inlinable
    public func putReportDefinition(_ input: PutReportDefinitionRequest, logger: Logger = AWSClient.loggingDisabled) async throws -> PutReportDefinitionResult {
        try await self.client.execute(
            operation: "PutReportDefinition", 
            path: "/reportDefinition", 
            httpMethod: .POST, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Creates the report definition for a report in Application Cost Profiler.
    ///
    /// Parameters:
    ///   - destinationS3Location: Required. Amazon Simple Storage Service (Amazon S3) location where Application Cost Profiler uploads the report.
    ///   - format: Required. The format to use for the generated report.
    ///   - reportDescription: Required. Description of the report.
    ///   - reportFrequency: Required. The cadence to generate the report.
    ///   - reportId: Required. ID of the report. You can choose any valid string matching the pattern for the ID.
    ///   - logger: Logger use during operation
    @inlinable
    public func putReportDefinition(
        destinationS3Location: S3Location,
        format: Format,
        reportDescription: String,
        reportFrequency: ReportFrequency,
        reportId: String,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> PutReportDefinitionResult {
        let input = PutReportDefinitionRequest(
            destinationS3Location: destinationS3Location, 
            format: format, 
            reportDescription: reportDescription, 
            reportFrequency: reportFrequency, 
            reportId: reportId
        )
        return try await self.putReportDefinition(input, logger: logger)
    }

    /// Updates existing report in AWS Application Cost Profiler.
    @Sendable
    @inlinable
    public func updateReportDefinition(_ input: UpdateReportDefinitionRequest, logger: Logger = AWSClient.loggingDisabled) async throws -> UpdateReportDefinitionResult {
        try await self.client.execute(
            operation: "UpdateReportDefinition", 
            path: "/reportDefinition/{reportId}", 
            httpMethod: .PUT, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Updates existing report in AWS Application Cost Profiler.
    ///
    /// Parameters:
    ///   - destinationS3Location: Required. Amazon Simple Storage Service (Amazon S3) location where Application Cost Profiler uploads the report.
    ///   - format: Required. The format to use for the generated report.
    ///   - reportDescription: Required. Description of the report.
    ///   - reportFrequency: Required. The cadence to generate the report.
    ///   - reportId: Required. ID of the report to update.
    ///   - logger: Logger use during operation
    @inlinable
    public func updateReportDefinition(
        destinationS3Location: S3Location,
        format: Format,
        reportDescription: String,
        reportFrequency: ReportFrequency,
        reportId: String,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> UpdateReportDefinitionResult {
        let input = UpdateReportDefinitionRequest(
            destinationS3Location: destinationS3Location, 
            format: format, 
            reportDescription: reportDescription, 
            reportFrequency: reportFrequency, 
            reportId: reportId
        )
        return try await self.updateReportDefinition(input, logger: logger)
    }
}

extension ApplicationCostProfiler {
    /// Initializer required by `AWSService.with(middlewares:timeout:byteBufferAllocator:options)`. You are not able to use this initializer directly as there are not public
    /// initializers for `AWSServiceConfig.Patch`. Please use `AWSService.with(middlewares:timeout:byteBufferAllocator:options)` instead.
    public init(from: ApplicationCostProfiler, patch: AWSServiceConfig.Patch) {
        self.client = from.client
        self.config = from.config.with(patch: patch)
    }
}

// MARK: Paginators

@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
extension ApplicationCostProfiler {
    /// Return PaginatorSequence for operation ``listReportDefinitions(_:logger:)``.
    ///
    /// - Parameters:
    ///   - input: Input for operation
    ///   - logger: Logger used for logging
    @inlinable
    public func listReportDefinitionsPaginator(
        _ input: ListReportDefinitionsRequest,
        logger: Logger = AWSClient.loggingDisabled
    ) -> AWSClient.PaginatorSequence<ListReportDefinitionsRequest, ListReportDefinitionsResult> {
        return .init(
            input: input,
            command: self.listReportDefinitions,
            inputKey: \ListReportDefinitionsRequest.nextToken,
            outputKey: \ListReportDefinitionsResult.nextToken,
            logger: logger
        )
    }
    /// Return PaginatorSequence for operation ``listReportDefinitions(_:logger:)``.
    ///
    /// - Parameters:
    ///   - maxResults: The maximum number of results to return.
    ///   - logger: Logger used for logging
    @inlinable
    public func listReportDefinitionsPaginator(
        maxResults: Int? = nil,
        logger: Logger = AWSClient.loggingDisabled        
    ) -> AWSClient.PaginatorSequence<ListReportDefinitionsRequest, ListReportDefinitionsResult> {
        let input = ListReportDefinitionsRequest(
            maxResults: maxResults
        )
        return self.listReportDefinitionsPaginator(input, logger: logger)
    }
}

extension ApplicationCostProfiler.ListReportDefinitionsRequest: AWSPaginateToken {
    @inlinable
    public func usingPaginationToken(_ token: String) -> ApplicationCostProfiler.ListReportDefinitionsRequest {
        return .init(
            maxResults: self.maxResults,
            nextToken: token
        )
    }
}
